<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.misc.*" %>
<%@ page import="com.dhec.ggs.*"%>
<%@ include file="/inc/init_include.jsp" %>
<%@ include file="/inc/config.jsp" %>
<%
DBI dbi2 = new DBI();
try{
	int dwgcount = dbi.getRecordNum("select count(*) from ggs_engineerchangenotice where iid>=65 and iid<=5368");
	int totalPage = Page.getPages(dwgcount, 100);
	
	for(int k=1;k<=totalPage;k++){
		String deleteIds = "";
		dbi.skipToPage(100, k, "select iId,sDcno from ggs_engineerchangenotice where iid>=65 and iid<=5368");
		ArrayList list = new ArrayList();
		while (dbi.rsNext()) {
			int iId = dbi.rsGetInt(1);
			String dcno = dbi.rsGetString(2);
			
			int dcnid = dbi2.getRecordNum("select iId from ggs_designchange where scruser='old system' and sdcno='"+dcno+"'");
			if(dcnid>0){
				dbi2.execute("update ggs_engineerchangenotice set idcnid="+dcnid+" where iId="+iId);
			}else
				deleteIds+=","+iId;
		}
		dbi.rsClose();
		if(deleteIds.length()>0)
			dbi2.execute("delete from ggs_engineerchangenotice where iId in ("+(deleteIds.substring(1))+")");
	}
	
	out.print("finish<br>");
}catch(Exception e){
	out.print(e);
}finally{
	dbi2.closeAll();
}
%>
<%@ include file="/inc/init_free.jsp" %>
